package Controller.Customer;;


import Service.CustomerService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "deleteCustomer", value = "/deleteCustomer")
public class DeleteCustomer extends HttpServlet {
    private CustomerService customerService = new CustomerService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Integer id = Integer.valueOf(request.getParameter("id"));
        try {
            customerService.deleteCustomer(id);
            request.getRequestDispatcher("/ListCustomer").forward(request, response);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}